package org.datastealer.dao.mysql;

import org.datastealer.bean.Schema;
import org.datastealer.dao.api.SchemaDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * Note：
 *
 * @author ：mengjw
 * @description：mysql数据库SchemaDAO实现
 * @date ：Created in 2020/8/23
 */
@Component("schemaDao")
public class MysqlSchemaDao implements SchemaDao {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * 查询全部schema的sql
     */
    @Value("${datastealer.mysql.schema.query}")
    private String querySchemaSql;

    @Override
    public List<Schema> getAllSchemas() {
        return jdbcTemplate.query(querySchemaSql, new BeanPropertyRowMapper<>(Schema.class));
    }

}